package com.yulongtian.oneProblemEveryDay.month202301;

/**
 * https://leetcode.cn/problems/min-max-game/
 * 可
 *
 * @author yulongTian
 * @create 2023-01-15 15:20
 */
public class Test12 {
    public static void main(String[] args) {

    }

    public static int minMaxGame(int[] nums) {
        int n = nums.length;
        if (n == 1) {
            return nums[0];
        }
        while (true) {
            if (nums[1] == -1) {
                break;
            }

            for (int i = 0; i < nums.length; i += 2) {
                if ((i / 2) % 2 == 0) {
                    nums[i / 2] = Math.min(nums[i], nums[i + 1]);
                } else {
                    nums[i / 2] = Math.max(nums[i], nums[i + 1]);
                }
            }
            nums[n / 2] = -1;
            n /= 2;
        }
        return nums[0];
    }
}
